(function($, window) {
	var CLASS_ACTIVE = 'mui-active';
	/**
	 * 自动消失提示框
	 */
	$.toast = function(message, time, cb) {
		// 只传两个参数，如果第二个参数是函数，则认为是callback
		if ($.isFunction(time) ) {
			cb = time;
			time = null;
		}

    time || (time = 2000);
    message = message || "";
    var toast = document.createElement('div');
    toast.classList.add('mui-toast-container');
    toast.innerHTML = '<span class="' + 'mui-toast-message' + '">' + message + '</span>';
    toast.addEventListener('webkitTransitionEnd', function() {
      if (!toast.classList.contains(CLASS_ACTIVE)) {
        toast.parentNode.removeChild(toast);
				cb && cb();
      }
    });
    document.body.appendChild(toast);
    toast.offsetHeight;
    toast.classList.add(CLASS_ACTIVE);
    setTimeout(function() {
      toast.classList.remove(CLASS_ACTIVE);
    }, time);
	};

	$.loading = function (i) {
		if (i == -1) {
			var lel = document.querySelector(".loading-wrapper");
	  	lel && document.body.removeChild(lel);
			return;
		}
  	var l = document.createElement('div');
		l.classList.add('loading-wrapper');
		l.innerHTML = `
		<div class="loader-inner ball-clip-rotate-multiple">
						<div></div>
						<div></div>
			</div>
		`
    document.body.appendChild(l);
	}



})(R, window);
